<template>
    <div class="container" @click="handleGallaryClick">
        <div class="wrapper">
            <swiper :options="swiperOption" class="swiper-container" v-if="hasImg">
                <swiper-slide v-for="item in gallaryImgs" :key="item">
                    <img :src="item" alt="">
                </swiper-slide>
                <div class="swiper-pagination"></div>
            </swiper>
        </div>
    </div>
</template>
<script>
import { computed } from 'vue'
export default {
  name: 'Gallary',
  props: {
    gallaryImgs: {
      type: Array
    }
  },
  setup(props, context){
    let swiperOption = {
      loop: true,
      observer: true,
      observeParents: true
    }
    let hasImg = computed(()=>{
      return props.gallaryImgs.length
    })
    function handleGallaryClick () {
      context.emit('close')
    }
    return { swiperOption, hasImg, handleGallaryClick } 
  }
}
</script>
<style lang="stylus" scoped>
.container
    z-index 99
    position fixed
    top 0
    bottom 0
    left 0
    right 0
    background-color #000
    display flex
    flex-direction column
    justify-content center
    .wrapper
        width 100%
        height 0
        padding-bottom 100%
        img
            width 100%
</style>
